using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace TestGUI
{
	/// <summary>
	/// This class is the main page the admin reaches when they first log in, and provides
	/// a link to all utilities an admin can implement.
	/// </summary>
	public class AdminWelcome : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Button changePassButton;
		private System.Windows.Forms.Button editPrefsButton;
		private System.Windows.Forms.Button logoutButton;
		Session ses;
		private System.Windows.Forms.Button editManagerAccountsButton;
		private System.Windows.Forms.Button clearButton;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public AdminWelcome()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}
		public AdminWelcome(Session s) 
		{
			InitializeComponent();
			ses = s;
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			ses.logout();
			this.Owner.Visible = true;
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.changePassButton = new System.Windows.Forms.Button();
			this.editPrefsButton = new System.Windows.Forms.Button();
			this.logoutButton = new System.Windows.Forms.Button();
			this.editManagerAccountsButton = new System.Windows.Forms.Button();
			this.clearButton = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("Arial", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(8, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(288, 32);
			this.label1.TabIndex = 0;
			this.label1.Text = "Welcome, Admin!";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(80, 72);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(152, 24);
			this.label3.TabIndex = 2;
			this.label3.Text = "What would you like to do?";
			// 
			// changePassButton
			// 
			this.changePassButton.Location = new System.Drawing.Point(72, 128);
			this.changePassButton.Name = "changePassButton";
			this.changePassButton.Size = new System.Drawing.Size(144, 24);
			this.changePassButton.TabIndex = 1;
			this.changePassButton.Text = "Change Password";
			this.changePassButton.Click += new System.EventHandler(this.changePassButton_Click);
			// 
			// editPrefsButton
			// 
			this.editPrefsButton.Location = new System.Drawing.Point(72, 96);
			this.editPrefsButton.Name = "editPrefsButton";
			this.editPrefsButton.Size = new System.Drawing.Size(144, 24);
			this.editPrefsButton.TabIndex = 0;
			this.editPrefsButton.Text = "Edit Preferences";
			this.editPrefsButton.Click += new System.EventHandler(this.editPrefsButton_Click);
			// 
			// logoutButton
			// 
			this.logoutButton.Location = new System.Drawing.Point(72, 224);
			this.logoutButton.Name = "logoutButton";
			this.logoutButton.Size = new System.Drawing.Size(144, 24);
			this.logoutButton.TabIndex = 4;
			this.logoutButton.Text = "Logout";
			this.logoutButton.Click += new System.EventHandler(this.logoutButton_Click);
			// 
			// editManagerAccountsButton
			// 
			this.editManagerAccountsButton.Location = new System.Drawing.Point(72, 160);
			this.editManagerAccountsButton.Name = "editManagerAccountsButton";
			this.editManagerAccountsButton.Size = new System.Drawing.Size(144, 24);
			this.editManagerAccountsButton.TabIndex = 4;
			this.editManagerAccountsButton.Text = "Edit Manager Accounts";
			this.editManagerAccountsButton.Click += new System.EventHandler(this.editManagerAccountsButton_Click);
			// 
			// clearButton
			// 
			this.clearButton.Location = new System.Drawing.Point(72, 192);
			this.clearButton.Name = "clearButton";
			this.clearButton.Size = new System.Drawing.Size(144, 24);
			this.clearButton.TabIndex = 4;
			this.clearButton.Text = "Clear All Data";
			this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
			// 
			// AdminWelcome
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 270);
			this.Controls.Add(this.changePassButton);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.editPrefsButton);
			this.Controls.Add(this.logoutButton);
			this.Controls.Add(this.editManagerAccountsButton);
			this.Controls.Add(this.clearButton);
			this.Name = "AdminWelcome";
			this.Text = "Welcome!";
			this.Load += new System.EventHandler(this.EmployeeWelcome_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void logoutButton_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void editPrefsButton_Click(object sender, System.EventArgs e)
		{
			Form f = new AdminPrefs(ses);
			this.AddOwnedForm(f);
			f.Owner = this;
			f.Visible = true;
			f.Activate();
			this.Visible = false;
		}

		private void changePassButton_Click(object sender, System.EventArgs e)
		{
			Form f = new AdminCP(ses);
			this.AddOwnedForm(f);
			f.Owner = this;
			f.Visible = true;
			f.Activate();
			this.Visible = false;
		}

		private void EmployeeWelcome_Load(object sender, System.EventArgs e)
		{
		
		}

		private void editManagerAccountsButton_Click(object sender, System.EventArgs e)
		{
			Form f = new ManagerList(ses);
			this.AddOwnedForm(f);
			f.Owner = this;
			f.Visible = true;
			f.Activate();
			this.Visible = false;
		}

		private void clearButton_Click(object sender, System.EventArgs e)
		{
			if (MessageBox.Show("Activating this function will clear all entries from the database. This means all employees, managers, and schedules will be removed from the database. Are you abso-fucking-lutely sure you want to do this?","Are you sure?",System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) 
			{
				return;
			} 
			if (MessageBox.Show("You're positive then.","Are you sure?",System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) 
			{
				return;
			} 
			MessageBox.Show("Your loss.");
			ses.clearAllData();
		}

	}
}
